
def lowbit(x):
    return x&(-x)

# a[x]+=y 影响后面的值
def add(x,y):

    while x<=n:
        tree[x]+=y
        x+=lowbit(x)

# 查询前缀和
def query(x):
    ans=0
    while x:
        ans+=tree[x]
        x-=lowbit(x)
    return ans


n,m=map(int,input().split())
a=[0]+list(map(int,input().split()))

tree=[0]*(n+1)
for i in range(1,n+1):
    add(i,a[i])

for _ in range(m):
    op=list(map(int,input().split()))
    if op[0]==1:
        add(op[1],op[2]-a[op[1]])
        # 原数组也要修改
        a[op[1]]=op[2]
    else:

        print((2*op[1]-n-2)*a[op[1]]-2*query(op[1]-1)+query(n))


